package com.cheer.controller;

import com.cheer.common.Page;
import com.cheer.common.Result;
import com.cheer.dto.MallShopQueryDTO;
import com.cheer.entity.SystemConfigEntity;
import com.cheer.service.SystemConfigService;
import com.cheer.vo.MallShopListVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author cheer
 */
@RestController
@RequestMapping("/sys")
@Api(tags = "系统设置")
public class SystemConfigController {

    @Autowired
    private SystemConfigService systemConfigService;


    @ApiOperation("配置列表分页 TODO(后续)")
    @PostMapping("/list")
    @PreAuthorize("@permissionValidator.isAdmin()")
    public Result<List<SystemConfigEntity>> list() {
        List<SystemConfigEntity> list = systemConfigService.list();
        return Result.success(list);
    }

    @ApiOperation("列表值的更新 TODO(后续)")
    @PostMapping("/update")
    @PreAuthorize("@permissionValidator.isAdmin()")
    public Result update( Integer id, String keyVal) {
        systemConfigService.updateById(id, keyVal);
        return Result.success();
    }


}
